Repository navigation
[ROCm][MiniMax-M3.1] Serve NVFP4 routed experts natively on gfx950 (AITER moe_nvfp4) + NIXL whole-row KV transfer for non-MLA BLHNC - #67793
Conversation
c5cf9c5 to
de55ccd
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
|
Thanks, Sergei! The NVFP4 path looks good to me. Could you rebase onto main and share the results of a MI355X PD smoke test using the final ROCm image? |
On gfx950 with AITER moe_nvfp4 (ROCm/aiter#7606), the NVFP4 routed experts of MiniMax-M3.1 checkpoints run on the AITER HIP kernels when no --quantization-config.moe is given: the CompressedTensors NVFP4 MoE method becomes MiniMaxM3NvFp4HipMoEMethod before weight loading (its backend selection is skipped) and feeds the checkpoint weights to aiter.ops.moe_nvfp4 for every T (no re-quantized copy, no modular kernel). --quantization-config.moe mxfp4|mxfp8 keeps the online re-quantization; other ROCm targets keep the error. EP, fused shared experts, padded MoE sizes and other SwiGLU-OAI parameters are rejected. The startup log notes that prefill (large T) may be slower than with --quantization-config.moe mxfp4. Signed-off-by: Sergei Shliapnikov <sergei.shliapnikov@amd.com>
With a block-outermost layout (BLHNC) one block row holds this rank's page of every layer. Only MLA models registered the row as one region; non-MLA models (e.g. MiniMax-M3.1) registered one region per layer, so a transfer took one descriptor per layer and block (64000 per 64k-token request instead of ~440), which exhausted UCX rendezvous fragments under load. A non-MLA row is head-sharded, so it can move whole only when P and D shard the heads alike: allow it and reject a TP mismatch at handshake. Signed-off-by: Sergei Shliapnikov <sergei.shliapnikov@amd.com>
a5b47f5 to
f3c942d
Compare
|
Thanks @zhou9402! Rebased onto main (99b0b0b) and re-tested. Image. Built with the official MI355X PD smoke (1P1D, NIXL, vllm-router). Same setup as in the PR description: P is TP4 MXFP8 and D is TP4 with native NVFP4. Compared with the pre-rebase image, nothing changed significantly, and the numbers match the ones in the description.
PD perf vs the pre-rebase image (k=7, synthetic acceptance; the pre-rebase numbers are the NVFP4 column of the full grid in the description):
ITL is equal or lower in every cell. Throughput differences are within 3%, inside the pass-to-pass spread of the pre-rebase runs. |
Purpose
Problem. MiniMax-M3.1 checkpoints (
quant_method: mxfp8,moe_quant_algo: NVFP4,moe_quant_format: nvfp4-pack-quantized) ship the routed experts as NVFP4. vLLM main has no NVFP4 MoE backend on ROCm, soMiniMaxM3MoEraisesNotImplementedErrorunless the user re-quantizes the experts online at load time:--quantization-config.moe mxfp8: the accurate option, but it doubles the routed-expert weight bytes (8.25 vs 4.5 bits per weight [A]) and decode is weight-bandwidth bound, so it is the slowest.--quantization-config.moe mxfp4: fast (4.25 bits per weight [A]), but it is a second, lossy quantization of weights that are already quantized (E8M0 block-32 scales replace the checkpoint FP8 block-16 scales plus global scale), and show accuracy 1.5-1.7 pp below MXFP8 on AIME26.Change. On gfx950 with an AITER build that contains
aiter.ops.moe_nvfp4(ROCm/aiter#7606), the checkpoint NVFP4 weights go unchanged to the AITER HIP NVFP4 MoE kernels for every token count. No flag and no env var.--quantization-config.moe mxfp8|mxfp4keeps the existing online re-quantization path unchanged. Without gfx950 or withoutaiter.ops.moe_nvfp4(for example today's stock image with AITER v0.1.29) the behavior is the same as today.Why: MXFP8 accuracy at MXFP4 speed. NVFP4 native serves the weights exactly as shipped, so it is a drop-in replacement for the MXFP8 re-quant option:
Second change: NIXL fix for P/D. Without it, P/D on vLLM main cannot serve M3.1 long contexts: NIXL moves the BLHNC KV cache in ~125 small pieces per block, and UCX runs out of resources at 8k C64 and 64k. The fix restores the whole-row transfer that the PR #63232 fork already had. Details in "PD fix: NIXL whole-row transfer".
Changes
2 commits, 4 files, +256 / -46 against dadf740.
[ROCm][MiniMax-M3] Serve NVFP4 routed experts on AITER moe_nvfp4: +190 / -37.[KV Connector][NIXL] Transfer whole packed rows for non-MLA BLHNC: +66 / -9.NVFP4 MoE (f59beb9).
vllm/models/minimax_m3/amd/model.py(+54 / -37): computeskeep_nvfp4(ModelOpt MXFP8 config withmoe_quant_algo == "NVFP4", experts not excluded, no online MoE quantization config). RaisesNotImplementedErroronly whenkeep_nvfp4 and not nvfp4_moe_supported(); the message says the model needs gfx950 and AITERmoe_nvfp4, otherwise use--quantization-config.moe mxfp8(ormxfp4).FusedMoEFactory(...)is built insideskip_checkpoint_backend_selection()whenkeep_nvfp4(the compressed-tensors NVFP4 MoE method creates the checkpoint parameters but skips its backend selection, which has no ROCm NVFP4 backend), thenkeep_nvfp4_experts(self.experts)is called. The factory arguments are unchanged; most of the -37 lines are the re-indent under thewithblock.vllm/models/minimax_m3/amd/nvfp4_experts.py(+136, new):nvfp4_moe_supported()= gfx950 andimport aiter.ops.moe_nvfp4succeeds.MiniMaxM3NvFp4HipMoEMethod(CompressedTensorsW4A4Nvfp4MoEMethod)buildsaiter.ops.moe_nvfp4.NvFp4MoeWeights(shuffled copies) inprocess_weights_after_loading, deletes the 8 checkpoint parameters so the weights are not held twice, and callsmoe_nvfp4(weights, x, topk_ids, topk_weights)inapply. Not monolithic, no modular kernel; the kernel takes bf16 activations and quantizes them internally.keep_nvfp4_expertschecks the method is exactlyCompressedTensorsW4A4Nvfp4MoEMethod, swaps its class before weight loading and logs once: "MiniMax-M3 NVFP4 routed experts: AITER moe_nvfp4 for every T. Prefill (large T) may be slower than with --quantization-config.moe mxfp4".Rejected at load (
NotImplementedError), limits of the AITER kernels: expert parallelism; fused shared experts (VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1, default 0); padded MoE sizes; any activation other than SwiGLU-OAI uninterleaved with alpha 1.702, beta 1.0, limit 7.0;apply_router_weight_on_input.Behavior notes. The routed scaling factor is applied by the runner (
RoutedScaleMode.OUTPUT, the existing non-FSE path). The shared expert is not overlapped through a modular kernel; the runner's shared-expert aux stream still applies. KV-cache capacity equals the re-quant flag (221.61 GiB at TP4) because the checkpoint parameters are freed.NIXL fix (c5cf9c5).
vllm/distributed/kv_transfer/kv_connector/v1/nixl/base_worker.py(+21 / -3): a non-MLA model whose KV views share one block-major allocation (BLHNC) and has no SSM state now registers whole block rows as one NIXL region, the same path MLA models already use. A P/D TP-size mismatch on such rows is rejected at handshake with "Packed KV rows of a non-MLA model need the same TP on prefill and decode ... Use LBHNC for heterogeneous TP."tests/v1/kv_connector/unit/test_nixl_desc_geometry.py(+45 / -6): 3 new tests (whole-row registration for pull and push workers at PP=1, TP-mismatch rejection).Dependency: AITER ROCm/aiter#7606
aiter.ops.moe_nvfp4(HIP kernels, ctypes entry, dispatch module, tuned CSV for M3.1 TP4 / TP8, op tests). It was still open on 2026-11-15.module_moe_nvfp4is an experimental module, so the stockPREBUILD_KERNELS=1wheel does not prebuild it and it JIT-compiles on first use (about 11 s) [V].flydsl==0.5.0(the v0.1.29 stack has 0.4.2). M3.1 gsm8k, AIME26 and perf ran on 0.5.0 without errors; other models that use vLLM FlyDSL kernels were not tested on 0.5.0.Docker build (official recipe)
AITER is built in the stack (
docker/Dockerfile.rocm_base, stagebuild_aiter), so the stack and runtime must be rebuilt in the same bake graph to get #7606 intovllm-openai:# After #7606 merges: AITER_BRANCH=main (or the first release tag with #7606). TAG=vllm-openai-rocm:m31-nvfp4-moe \ docker buildx bake -f docker/docker-bake-rocm.hcl vllm-openai \ --set stack-rocm.args.AITER_REPO=https://github.com/sshlyapn/aiter.git \ --set stack-rocm.args.AITER_BRANCH=sshliapn/features/cdna4_nvfp4_moeServing: P/D decode node (MI355X)
Setup. This is the decode command of the official vLLM MI355X MiniMax-M3.1 P/D recipe with the minimum changes for NVFP4 decode. The prefill node keeps MXFP8 re-quantized experts with
VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=1; every P/D result in this description used such a P (details below).Differences from the official decode command (3 lines).
--quantization-config.moe: the routed experts stay in the checkpoint NVFP4 format and run on AITERmoe_nvfp4. Startup logs "MiniMax-M3 NVFP4 routed experts: AITER moe_nvfp4 for every T ...". Adding--quantization-config.moe mxfp8(ormxfp4) back gives the unchanged re-quant path.VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0: required; the NVFP4 path rejects fused shared experts at load ("fused shared experts are unsupported"). The shared expert runs as a separate module.aiter.ops.moe_nvfp4([HIP] [JIT] [MoE] NVFP4 routed-expert MoE for gfx950 ROCm/aiter#7606), for example the tag built in "Docker build". Our P and D both ran the same image with the NIXL commit of this PR; a P without the NIXL commit paired with a D with it was not tested.VLLM_KV_CACHE_LAYOUT=BLHNCthe NIXL fix requires equal P and D TP (TP4 / TP4 here); a mismatch fails at handshake. The fix does not change LBHNC.Accuracy
All runs: MI355X (gfx950), TP4 per engine, MiniMax-M3.1-Flash. AIME26 = sgl-eval, 16 repeats per run, max_tokens 65536, temperature 1.0, top-p 0.95, thinking_mode enabled. 1P1D = P TP4 MXFP8 re-quant (+FSE), D TP4 = the arm. Error rate 0 in every run [V].
Paired per problem (30 problems x 64 repeats) [V]:
Performance
1P1D PD, full grid, NVFP4 vs MXFP4 vs MXFP8 (2026-11-15, this PR stack + NIXL fix)
Setup. P = MXFP8 re-quant + FSE=1 for every arm; D = NVFP4 native (FSE=0), MXFP4 re-quant (FSE=1) or MXFP8 re-quant (FSE=1), same image. DSpark MTP k=7 with synthetic acceptance [0.77, 0.55, 0.39, 0.27, 0.19, 0.14, 0.10]; random prefix ISL 1k / 8k / 64k, OSL 1024, C 1 / 8 / 16 / 32 / 64, warmup per C, 2 passes in palindrome order (MXFP8, MXFP4, NVFP4, NVFP4, MXFP4, MXFP8). 0 failed requests; pass-to-pass ITL 0.97-1.03. Values are means of 2 passes [V]; speedups [A].
PD fix: NIXL whole-row transfer for non-MLA BLHNC
What it does. With a block-outermost KV layout (BLHNC), one block row holds this rank's page of every layer (for M3.1 TP4: 1,822,720 B per 128-token block [V, D log]). On vLLM main the NIXL connector registers such a row as one region only for MLA models. M3.1 is not MLA, so it registers one region per layer and KV kind; a block then moves as ~125 separate descriptors of a few KB to ~18 KB each (18,432 B for a main-attention page [V, unfixed D log]; ~14.6 KB on average [A]). With the fix a block moves as one 1.74 MiB descriptor. The bytes moved, the READ path, the block pairing and the completion notifications do not change; only the registration granularity and the descriptor count do.
Why it is needed.
UCX_RMA_PPLN_ENABLE=yit then ran out of shared-memory segments (shmgetENOSPC, hostkernel.shmmni4096) from 8k C64 and at 64k C16, with ~42k transfer errors [V].Origin: replicated from the PR #63232 fork. The PR #63232 branch (squashed commit 36ae880, 2026-10-23; head 8d0f05a) already allowed whole-row transfer for non-MLA models with the same TP-mismatch check. This commit restores it: the accepted cases are the same boolean condition as in the fork (written as a separate
packed_head_sharded_storageflag next to main'sreplicated_shared_storage), and the handshake check is the fork's code verbatim. The 3 unit tests are new. Credit for the logic goes to the #63232 authors.Limits.
--disable-hybrid-kv-cache-manager(one group).AIME26 test command
No new vLLM unit test for the NVFP4 MoE path: it needs gfx950 and an AITER build with
moe_nvfp4, which current vLLM CI images do not have. Without the op,nvfp4_moe_supported()is False and the sameNotImplementedErrorpath is kept by construction (not run as a separate test).